<template>
  <div>
    <el-tabs
      v-model="activeName2"
      type="card"
      v-loading="loading3"
      element-loading-text="数据加载中。。。。"
      element-loading-spinner="el-icon-loading"
    >
      <el-tab-pane label="基础信息" name="second">
        <div class="second-contain">
          <div class="head">
            <h1>基础信息</h1>
          </div>
          <div class="second-contain-box ma">
            <el-row>
              <el-col :span="8">
                <span>学生姓名：{{stuTableData.studentInfo.name}}</span>
              </el-col>
              <el-col :span="8">
                <span>学校名称：{{stuTableData.studentInfo.school}}</span>
              </el-col>
              <el-col :span="8">
                <span>学籍号：{{stuTableData.studentInfo.oemAccount}}</span>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <span>学制：{{stuTableData.studentInfo.schoolSystem}}</span>
              </el-col>
              <el-col :span="8">
                <span>就读年级：{{stuTableData.studentInfo.grade}}</span>
              </el-col>
              <el-col :span="8">
                <span>科目：{{stuTableData.studentInfo.subject}}</span>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <span>家长姓名：{{stuTableData.studentInfo.parentName}}</span>
              </el-col>
              <el-col :span="8">
                <span>联系电话：{{stuTableData.studentInfo.phone}}</span>
              </el-col>
              <el-col :span="8">
                <span>备用电话：{{stuTableData.studentInfo.sparePhone}}</span>
              </el-col>
            </el-row>
            <el-row>
              <el-col v-if="!this.customerSource" :span="8">
                <span>客户来源：{{stuTableData.studentInfo.dataFrom}}</span>
              </el-col>
              <el-col v-if="!this.customerImportDepartment" :span="8">导入部门：{{stuTableData.studentInfo.importDepartment}}</el-col>
              <el-col :span="8">设备：{{stuTableData.studentInfo.equipment}}</el-col>
            </el-row>
            <el-row>
              <el-col :span="8">推广来源：{{stuTableData.studentInfo.source}}</el-col>
              <el-col :span="8">
                页面地址：
                <!-- <a
                  v-if="isUrl"
                  :href="'http://'+stuTableData.studentInfo.pageAddress"
                  target="_blank"
                >{{stuTableData.studentInfo.pageAddress}}</a> -->
                <a
                  v-if="isUrl"
                  :href="stuTableData.studentInfo.pageAddress"
                  target="_blank"
                >{{stuTableData.studentInfo.pageAddress}}</a>
                <span v-if="isnotUrl">{{stuTableData.studentInfo.pageAddress}}</span>
              </el-col>
              <el-col :span="8">分主题：{{stuTableData.studentInfo.keyWords}}</el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <span>账号：{{stuTableData.studentInfo.account}}</span>
              </el-col>
              <el-col :span="16">
                <span>地区：{{address+stuTableData.studentInfo.areaInput}}</span>
              </el-col>
            </el-row>
            
            <el-row>
              <el-col :span="24">
                <span>备注：{{stuTableData.studentInfoAttr.comment}}</span>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <span>创建时间：{{stuTableData.studentInfo.createDate}}</span>
              </el-col>
              <el-col :span="8">
                <span>更新时间：{{stuTableData.studentInfo.updateDate}}</span>
              </el-col>
            </el-row>
          </div>
        </div>
        <div class="second-contain" style="margin-top:20px">
          <div class="head">
            <h1>客户信息</h1>
          </div>
          <div class="second-contain-box ma">
            <el-row>
              <el-col :span="8">
                <span>客户类型：{{stuTableData.studentInfo.type}}</span>
              </el-col>
              <el-col :span="8">
                <span>客户进展：{{stuTableData.studentInfo.progress}}</span>
              </el-col>
              <el-col :span="8">
                <span>获取方式：{{stuTableData.studentInfo.dataFromType}}</span>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <span>性别：{{stuTableData.studentInfo.sex}}</span>
              </el-col>
              <el-col :span="8">
                <span>年龄：{{stuTableData.studentInfo.age}}</span>
              </el-col>
              <el-col :span="8">
                <span>身份证号：{{stuTableData.studentInfo.idCard}}</span>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <span>微信：{{stuTableData.studentInfo.wechat}}</span>
              </el-col>
              <el-col :span="8">
                <span>QQ:{{stuTableData.studentInfo.qq}}</span>
              </el-col>
              <el-col :span="8">
                <span>邮箱：{{stuTableData.studentInfo.email}}</span>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <span>与家长关系：{{stuTableData.studentInfo.relationShip}}</span>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24" class="address">
                薄弱学科：
                <span
                  v-for="item in stuTableData.studentInfoAttr.weakSubject"
                  v-bind:key="item.index"
                >{{item}}</span>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24" class="address">
                专业能力：
                <span
                  v-for="item in stuTableData.studentInfoAttr.likeProfessionAbility"
                  v-bind:key="item.index"
                >{{item}}</span>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24" class="address">
                授课方式：
                <span
                  v-for="item in stuTableData.studentInfoAttr.likeLectureStyle"
                  v-bind:key="item.index"
                >{{item}}</span>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24" class="address">
                语言表达：
                <span
                  v-for="item in stuTableData.studentInfoAttr.likeExpression"
                  v-bind:key="item.index"
                >{{item}}</span>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24" class="address">
                讲义板书：
                <span
                  v-for="item in stuTableData.studentInfoAttr.likeBlackboardWriting"
                  v-bind:key="item.index"
                >{{item}}</span>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24" class="address">
                家长类型：
                <span
                  v-for="item in stuTableData.studentInfoAttr.parentType"
                  v-bind:key="item.index"
                >{{item}}</span>
              </el-col>
            </el-row>
          </div>
        </div>
        <div class="second-contain" style="margin-top:20px">
          <div class="head">
            <h1>签约信息</h1>
          </div>
          <div class="second-contain-box ma">
            <el-row v-for="item in listStudentSignInfo" v-bind:key="item.index">
              <el-col :span="6">
                <span>订单号：{{item.orderId}}</span>
              </el-col>
              <el-col :span="6">
                <span>成单产品：{{item.product}}</span>
              </el-col>
              <el-col :span="6">
                <span>成单金额：{{item.money}}元</span>
              </el-col>
              <el-col :span="6">
                <span>课时数：{{item.classNum}}</span>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24" class="address">
                成单对策：
                <span
                  v-for="item in stuTableData.studentInfoAttr.signStrategy"
                  v-bind:key="item.index"
                >{{item}}</span>
              </el-col>
            </el-row>
          </div>
          <!-- <div class="second-contain-box ma">
            <el-row>
              <el-col :span="24">
                <span>备注：{{stuTableData.studentInfoAttr.comment}}</span>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <span>创建时间：{{stuTableData.studentInfo.createDate}}</span>
              </el-col>
              <el-col :span="12">
                <span>更新时间：{{stuTableData.studentInfo.updateDate}}</span>
              </el-col>
            </el-row>
          </div> -->
        </div>
      </el-tab-pane>
      <el-tab-pane label="跟进情况" name="third">
        <div class="third-contain-box">
          <div class="head">
            <h1>客户跟进</h1>
          </div>
          <Crm-table
            :showBatchDelete="showBatchDelete"
            class="table-width"
            :data="stuqueryTrackingData"
            :columns="columns"
            :loading="loading"
            @findPage="findPage"
            @handleSee="handleSee"
          ></Crm-table>
        </div>
        <div class="third-contain-box">
          <div class="head">
            <h1>外呼记录</h1>
          </div>
          <Crm-table
            :showBatchDelete="showBatchDelete"
            class="table-width"
            permsEdit="sys:user:edit"
            permsDelete="sys:user:delete"
            :data="studentCallInfoList"
            :columns="columns2"
            @findPage2="findPage2"
            :loading="loading1"
          ></Crm-table>
        </div>
        <div class="third-contain-box">
          <div class="head">
            <h1>订单信息</h1>
          </div>
          <Crm-table
            :showBatchDelete="showBatchDelete"
            :order="false"
            class="table-width"
            permsEdit="sys:user:edit"
            permsDelete="sys:user:delete"
            :data="listStudentSignInfoData"
            :loading="loading2"
            :columns="columns3"
          ></Crm-table>
        </div>
      </el-tab-pane>
      <!-- <el-tab-pane label="学生评测" name="fourth">学生评测内容</el-tab-pane> -->
    </el-tabs>
    <kt-button
      class="stu-btn"
      :label="$t('action.close')"
      perms="true"
      size="medium"
      @click="closeSelectedTag()"
    />
  </div>
</template>
<script>
import { hasPermission } from "@/permission/index.js";
import axios from "axios";
import KtButton from "@/views/Core/KtButton";
import api from "@/http/api";
import CrmTable from "@/views/Core/CrmTable";
import { CodeToText } from "element-china-area-data";
import { isURL } from "@/utils/validate";
export default {
  name: "Student",
  components: {
    KtButton,
    CrmTable
  },
  data: function() {
    return {
      // filters: {
      //     name: ""
      // },
      isUrl: false,
      isnotUrl: false,
      loading: false,
      loading3: false,
      loading1: false,
      loading2: false,
      selection: false,
      showBatchDelete: false,
      customerSource: false,
      customerImportDepartment:false,
      activeName2: "second",
      stuTableData: {
        studentInfo: {
          areaInput: ""
        },
        studentInfoAttr: {}
      },
      address: "",
      listStudentSignInfo: [],
      // 客户跟进数据
      stuqueryTrackingData: {
        content: []
      },
      studentCallInfoList: {
        content: []
      },
      listStudentSignInfoData: {
        content: []
      },
      type: [],
      student_progress_options: [],
      student_communication_type: [],
      // 订单表格数据
      columns: [
        { type: "index", label: "序号", minWidth: 10 },
        { prop: "contractDate", label: "跟进时间", minWidth: 100 },
        { prop: "contactPeople", label: "联系人", minWidth: 50 },
        { prop: "contractResult2", label: "沟通结果", minWidth: 50 },
        { prop: "contractType", label: "沟通形式", minWidth: 50 },
        { prop: "customerType", label: "客户类型", minWidth: 80 },
        { prop: "getprogress", label: "客户进展", minWidth: 50 },
        { prop: "trackingPeople", label: "跟进人", minWidth: 100 },
        { prop: "contractContent", label: "沟通内容", minWidth: 140 },
        { prop: "nextContractDate", label: "下次跟进时间", minWidth: 100 }
      ],
      columns2: [
        { type: "index", label: "序号", minWidth: 10 },
        { prop: "callDate", label: "外呼时间", minWidth: 80 },
        { prop: "connect", label: "是否接通", minWidth: 80 },
        { prop: "timeLength", label: "通话时长（秒）", minWidth: 80 },
        { prop: "seatCode", label: "坐席号", minWidth: 100 },
        { prop: "tqCode", label: "TQ号", minWidth: 70 },
        { prop: "callPeopleStr", label: "外呼人员", minWidth: 100 }
      ],
      columns3: [
        { prop: "orderId", label: "订单号", minWidth: 100 },
        { prop: "product", label: "订单产品", minWidth: 80 },
        { prop: "money", label: "订单金额", minWidth: 80 },
        { prop: "signDate", label: "订单时间", minWidth: 80 }
      ],
      pageResult: {},
      pageSize: 0,
      pageNum: 0,
      pageRequest: { pageNum: 1, pageSize: 8 },
      student_import_department: [],
      student_result_options: [],
      student_equipmentgrade_options: [],
      student_TGsource_options: [],
      roleId: "", //当前登录用户的角色id
      // roleId1: "307922416041209975", //咨询师
      // roleId2: "307922480151146627", //直销三级部门管理
      // roleId3: "307922544034590863", //直销部门管理
      // roleId4: "318843899038940998", //金丰和校区管理
      // roleId5: "318845886098849661", //金丰和班主任管理
    };
  },
  watch: {
    // $route: "getParams"
  },
  beforeMount: function() {
    //   请求页面传过来的ID根据ID发送请求
    let routerParams = this.$route.query;
  },
  methods: {
    hasPerms: function(perms) {
      // 根据权限标识和外部指示状态进行权限判断
      return hasPermission(perms) & !this.disabled;
    },
    handleSee(params) {
      this.dataForm = Object.assign({}, params.row);
      this.$router.push({
        path: "/Follow/StudentFollow",
        query: {
          id: params.row.id,
          studentName: this.stuTableData.studentInfo.name
        }
      });
    },
    isActive(route) {
      return route.path === this.$route.path;
    },
    closeSelectedTag(view) {
      this.$store.dispatch("delVisitedViews", this.$route).then(views => {
        if (this.isActive(this.$route)) {
          const latestView = views.slice(-1)[0];
          if (latestView) {
            this.$router.push(latestView);
          } else {
            this.$router.push("/");
          }
        }
      });
    },
    get_page_data() {
      this.loading3 = true;
      this.$api.student
        .studentQueryInfoWithEscape({
          id: this.$route.query.id
        })
        .then(res => {
          this.stuTableData.studentInfo = res.studentInfo;
          this.stuTableData.studentInfoAttr = res.studentInfoAttr;
          let reg = new RegExp("(\\d{4})(\\d{2})(\\d{5})");
          if(this.stuTableData.studentInfo.phone){
            this.stuTableData.studentInfo.phoneStr=this.stuTableData.studentInfo.phone.replace(reg, "$1**$3");
          }
          
          this.getURL();
          this.loading3 = false;
          // this.address=res.studentInfo.province +res.studentInfo.city+res.studentInfo.area
          // this.address = CodeToText[res.studentInfo.province] + CodeToText[res.studentInfo.city] + CodeToText[res.studentInfo.area];
          // 导入部门转义
          this.student_import_department.forEach(item => {
            if (item.key == this.stuTableData.studentInfo.importDepartment) {
              this.stuTableData.studentInfo.importDepartment = item.value;
            }
          });
          if (
            (res.studentInfo.province == null) &
            (res.studentInfo.city == null) &
            (res.studentInfo.area == null) &
            (res.studentInfo.areaInput == null)
          ) {
            this.address = " ";
            this.stuTableData.studentInfo.areaInput = "";
          } else if (res.studentInfo.areaInput == null) {
            this.address =
              res.studentInfo.province +
              res.studentInfo.city +
              res.studentInfo.area;
            this.stuTableData.studentInfo.areaInput = "";
          } else if (
            (res.studentInfo.province != null) &
            (res.studentInfo.city != null) &
            (res.studentInfo.area != null) &
            (res.studentInfo.areaInput != null)
          ) {
            this.address =
              res.studentInfo.province +
              res.studentInfo.city +
              res.studentInfo.area;
            this.stuTableData.studentInfo.areaInput = res.studentInfo.areaInput;
          }
          // 学制
          this.system_cache = JSON.parse(localStorage.getItem("systemCache"));
          this.system_cache.forEach(item => {
            if (item.fId == this.stuTableData.studentInfo.schoolSystem) {
              this.stuTableData.studentInfo.schoolSystem = item.fSystemName;
            }
          });
          // 年级
          this.grade_cache = JSON.parse(localStorage.getItem("gradeCache"));
          this.grade_cache.forEach(item => {
            if (item.fId == this.stuTableData.studentInfo.grade) {
              this.stuTableData.studentInfo.grade = item.fGradeName;
            }
          });
          //科目
          this.subject_options = JSON.parse(
            localStorage.getItem("studentSubject")
          );
          this.subject_options.forEach(item => {
            if (item.fId == this.stuTableData.studentInfo.subject) {
              this.stuTableData.studentInfo.subject = item.fSpecialtyName;
            }
          });
          //    客户来源
          this.$api.user
            .optionsList({ codeType: "student_data_from" })
            .then(res => {
              this.student_data_from = res.keyValueList;
              this.student_data_from.forEach(item => {
                if (item.key == this.stuTableData.studentInfo.dataFrom) {
                  this.stuTableData.studentInfo.dataFrom = item.value;
                }
              });
            });
          // 网推的一些东西转义（设备、推广来源）
          // 转换推广设备
          this.student_equipmentgrade_options.forEach(equipmentItem => {
            if (equipmentItem.key == this.stuTableData.studentInfo.equipment) {
              this.stuTableData.studentInfo.equipment = equipmentItem.value;
            }
          });
          // 转换推广来源
          this.student_TGsource_options.forEach(TGsourceItem => {
            if (TGsourceItem.key == this.stuTableData.studentInfo.source) {
              this.stuTableData.studentInfo.source = TGsourceItem.value;
            }
          });
          // 客户类型
          this.get_customer_type();
          // 客户进展
          this.get_progress();
          // 薄弱学科
          this.$api.user
            .optionsList({ codeType: "student_weak_subject" })
            .then(res => {
              this.weak_subject = res.keyValueList;
              let subject = this.stuTableData.studentInfoAttr.weakSubject;
              if (subject == null) {
                subject = "";
              } else {
                subject = this.stuTableData.studentInfoAttr.weakSubject.split(
                  ","
                );
                var aa = [];
                subject.forEach(subject_item => {
                  this.weak_subject.forEach(item => {
                    if (item.key == subject_item) {
                      aa.push(item.value);
                      this.stuTableData.studentInfoAttr.weakSubject = aa;
                    }
                  });
                });
              }
            });
          // 专业能力
          this.$api.user
            .optionsList({ codeType: "student_like_profession_ability" })
            .then(res => {
              this.ability = res.keyValueList;
              let abilitys = this.stuTableData.studentInfoAttr
                .likeProfessionAbility;
              if (abilitys == null) {
                abilitys = "";
              } else {
                abilitys = this.stuTableData.studentInfoAttr.likeProfessionAbility.split(
                  ","
                );
                var bb = [];
                abilitys.forEach(subject_item => {
                  this.ability.forEach(item => {
                    if (item.key == subject_item) {
                      bb.push(item.value);
                      this.stuTableData.studentInfoAttr.likeProfessionAbility = bb;
                    }
                  });
                });
              }
            });
          // 授课方式
          this.$api.user
            .optionsList({ codeType: "student_like_lecture_style" })
            .then(res => {
              this.style = res.keyValueList;
              let styles = this.stuTableData.studentInfoAttr.likeLectureStyle;
              if (styles == null) {
                styles = "";
              } else {
                styles = this.stuTableData.studentInfoAttr.likeLectureStyle.split(
                  ","
                );
                let cc = [];
                styles.forEach(subject_item => {
                  this.style.forEach(item => {
                    if (item.key == subject_item) {
                      cc.push(item.value);
                      this.stuTableData.studentInfoAttr.likeLectureStyle = cc;
                    }
                  });
                });
              }
            });
          // 语言表达
          this.$api.user
            .optionsList({ codeType: "student_like_expression" })
            .then(res => {
              this.expression = res.keyValueList;
              let expressions = this.stuTableData.studentInfoAttr
                .likeExpression;
              if (expressions == null) {
                expressions = "";
              } else {
                expressions = this.stuTableData.studentInfoAttr.likeExpression.split(
                  ","
                );
                let aa = [];
                expressions.forEach(subject_item => {
                  this.expression.forEach(item => {
                    if (item.key == subject_item) {
                      aa.push(item.value);
                      this.stuTableData.studentInfoAttr.likeExpression = aa;
                    }
                  });
                });
              }
            });
          // 讲义板书
          this.$api.user
            .optionsList({ codeType: "student_like_blackboard_writing" })
            .then(res => {
              this.writing = res.keyValueList;
              let writings = this.stuTableData.studentInfoAttr
                .likeBlackboardWriting;
              if (writings == null) {
                writings = "";
              } else {
                writings = this.stuTableData.studentInfoAttr.likeBlackboardWriting.split(
                  ","
                );
                let aa = [];
                writings.forEach(subject_item => {
                  this.writing.forEach(item => {
                    if (item.key == subject_item) {
                      aa.push(item.value);
                      this.stuTableData.studentInfoAttr.likeBlackboardWriting = aa;
                    }
                  });
                });
              }
            });
          // 家长类型
          this.$api.user
            .optionsList({ codeType: "student_parent_type" })
            .then(res => {
              this.parent = res.keyValueList;
              let parents = this.stuTableData.studentInfoAttr.parentType;
              if (parents == null) {
                parents = "";
              } else {
                parents = this.stuTableData.studentInfoAttr.parentType.split(
                  ","
                );
                let aa = [];
                parents.forEach(subject_item => {
                  this.parent.forEach(item => {
                    if (item.key == subject_item) {
                      aa.push(item.value);
                      this.stuTableData.studentInfoAttr.parentType = aa;
                    }
                  });
                });
              }
            });
          // 成单对策
          this.$api.user
            .optionsList({ codeType: "student_sign_strategy" })
            .then(res => {
              this.strategy = res.keyValueList;
              let strategys = this.stuTableData.studentInfoAttr.signStrategy;
              if (strategys == null) {
                strategys = this.stuTableData.studentInfoAttr.signStrategy;
              } else {
                strategys = this.stuTableData.studentInfoAttr.signStrategy.split(
                  ","
                );
                let aa = [];
                strategys.forEach(subject_item => {
                  this.strategy.forEach(item => {
                    if (item.key == subject_item) {
                      aa.push(item.value);
                      this.stuTableData.studentInfoAttr.signStrategy = aa;
                    }
                  });
                });
              }
            });
          if (
            this.stuTableData.studentInfo.sex == 1 ||
            this.stuTableData.studentInfo.sex == "男"
          ) {
            this.stuTableData.studentInfo.sex = "男";
          } else if (
            this.stuTableData.studentInfo.sex == 2 ||
            this.stuTableData.studentInfo.sex == "女"
          ) {
            this.stuTableData.studentInfo.sex = "女";
          } else this.stuTableData.studentInfo.sex = "";
        });
    },
    //  获取订单信息
    get_order_data() {
      this.$api.user
        .optionsList({ codeType: "student_order_product" })
        .then(res => {
          this.student_order_product_options2 = res.keyValueList;
        });
      this.$api.student
        .studentSignList({
          studentId: this.$route.query.id
        })
        .then(res => {
          this.listStudentSignInfo = res.listStudentSignInfo;
          let content = {
            content: res.listStudentSignInfo,
            totalSize: res.total
          };
          this.listStudentSignInfoData = content;
          this.loading = false;
          this.listStudentSignInfoData.content.forEach(item => {
            this.$api.user
              .optionsList({ codeType: "student_order_product" })
              .then(res => {
                this.student_order_product = res.keyValueList;
                this.student_order_product.forEach(
                  student_order_product_item => {
                    if (student_order_product_item.key == item.product) {
                      item.product = student_order_product_item.value;
                    }
                  }
                );
              });
          });
        });
    },
    get_student_info() {
      //    客户来源
      this.$api.user
        .optionsList({ codeType: "student_data_from" })
        .then(res => {
          this.student_data_from = res.keyValueList;
        });
    },
    // 查询学生跟进列表
    findPage(data) {
      if (data !== null) {
        this.loading = true;
        this.pageRequest = data.pageRequest;
      }
      this.$api.student
        .queryStudentTrackingList({
          studentId: this.$route.query.id,
          pageSize: this.pageRequest.pageSize,
          pageNum: this.pageRequest.pageNum
        })
        .then(res => {
          let content = {
            content: res.listStudentTrackingInfo,
            totalSize: res.total
          };
          this.stuqueryTrackingData = content;
          this.loading = false;
          this.stuqueryTrackingData.content.forEach(item => {
            this.student_progress_options = JSON.parse(
              localStorage.getItem("studenProgress")
            );
            this.student_progress_options.forEach(progress_item => {
              if (progress_item.key == item.customerProgress) {
                item.getprogress = progress_item.value;
              }
            });
            this.type = JSON.parse(localStorage.getItem("stdentTpye"));
            this.type.forEach(type_item => {
              if (type_item.key == item.customerType) {
                item.customerType = type_item.value;
              }
            });
            this.student_communication_type = JSON.parse(
              localStorage.getItem("contractType")
            );
            this.student_communication_type.forEach(communication_item => {
              if (communication_item.key == item.contractType) {
                item.contractType = communication_item.value;
              }
            });

            // 沟通结果转换
            this.student_result_options.forEach(result_item => {
              if (result_item.key == item.contractResult) {
                item.contractResult2 = result_item.value;
              }
            });
          });
        })
        .then(data != null ? data.callback : "");
    },
    // 获取外呼记录
    findPage2(data) {
      if (data !== null) {
        this.loading = true;
        this.pageRequest = data.pageRequest;
      }
      this.$api.student
        .queryStudentCallList({
          studentId: this.$route.query.id,
          pageSize: this.pageRequest.pageSize,
          pageNum: this.pageRequest.pageNum
        })
        .then(res => {
          let content = {
            content: res.studentCallInfoList,
            totalSize: res.total
          };
          this.studentCallInfoList = content;
          this.loading = false;
          this.studentCallInfoList.forEach;
          this.studentCallInfoList.content.forEach(item => {
            item.connect = item.isGetThrough == 1 ? "接通" : "未接通";
          });
        });
    },
    // 客户类型
    get_customer_type() {
      this.$api.user.optionsList({ codeType: "student_type" }).then(res => {
        this.type = res.keyValueList;
        this.type.forEach(item => {
          if (item.key == this.stuTableData.studentInfo.type) {
            this.stuTableData.studentInfo.type = item.value;
          }
        });
      });
    },
    // 客户进展
    get_progress() {
      this.$api.user.optionsList({ codeType: "student_progress" }).then(res => {
        this.student_progress_options = res.keyValueList;
        this.student_progress_options.forEach(item => {
          if (item.key == this.stuTableData.studentInfo.progress) {
            this.stuTableData.studentInfo.progress = item.value;
          }
        });
      });
    },
    // 获取导入部门
    get_student_importDepartment() {
      this.$api.user
        .optionsList({ codeType: "student_import_department" })
        .then(res => {
          this.student_import_department = res.keyValueList;
        });
    },

    // 获取沟通结果
    get_result() {
      this.student_result_options = JSON.parse(
        localStorage.getItem("progressResult")
      );
    },

    // 获取网推的下拉选项
    get_TG_options() {
      this.student_equipmentgrade_options = JSON.parse(
        localStorage.getItem("studentEquipment")
      );
      this.student_TGsource_options = JSON.parse(
        localStorage.getItem("studentTGsource")
      );
    },

    // 判断页面地址
    getURL() {
      if (isURL(this.stuTableData.studentInfo.pageAddress)) {
        this.isUrl = true;
        this.isnotUrl = false;
      } else if (!isURL(this.stuTableData.studentInfo.pageAddress)) {
        this.isUrl = false;
        this.isnotUrl = true;
      }
    },
    // 查询角色信息
    queryUserRole() {
      let identity = this.$route.query.identity;
      this.$api.role.queryUserRole().then(res => {
        if (res.result == 1) {
          this.roleId = res.userInfo.roleId;
          if (
            (this.roleId == this.roleId1 ||
              this.roleId == this.roleId2 ||
              this.roleId == this.roleId3 ||
              this.roleId == this.roleId4 ||
              this.roleId == this.roleId5) &&
            identity == undefined
          ) {
            this.customerSource = true;
            this.customerImportDepartment=true
          } else if (
            (this.roleId == this.roleId1 ||
              this.roleId == this.roleId2 ||
              this.roleId == this.roleId3 ||
              this.roleId == this.roleId4 ||
              this.roleId == this.roleId5) &&
            identity == 1
          ) {
            this.customerSource = false;
            this.customerImportDepartment=false
          }
        }
      });
    }
  },

  mounted() {
    this.queryUserRole();
    this.get_student_info();
    this.get_page_data();
    this.get_order_data();
    this.get_progress();
    this.get_customer_type();
    this.get_result();
    this.get_student_importDepartment();
    this.get_TG_options();
  },
  created() {}
};
</script>
<style lang='scss' scoped>
.third-contain-box {
  text-align: left;
  width: 90%;
  margin: 20px auto;
  border: 1px solid #e4e7ed;
  overflow: hidden;
  .head h1 {
    font-size: 20px;
    font-weight: bold;
    padding: 20px;
  }
}
.second-contain {
  text-align: left;
  width: 90%;
  margin: 0 auto;
  border: 1px solid #e4e7ed;
  .head h1 {
    font-size: 20px;
    font-weight: bold;
    padding: 20px;
  }
  .second-contain-box {
    width: 95%;
    margin: 0 auto;
    .el-row {
      margin-bottom: 20px;
    }
    .el-form {
      display: flex;
      flex-direction: row;
      justify-content: space-around;
      .el-form-item {
        display: flex;
        margin-left: 20px;
      }
    }
    .el-table td {
      border-bottom: 0px !important;
    }
    .address span {
      display: inline-block;
      margin: 0 20px;
    }
  }
}
.stu-btn {
  margin: 20px 0;
}
</style>
<style lang="scss">
.second-contain-box {
  width: 95%;
  .el-table td,
  .el-table th.is-leaf {
    border-bottom: 0px !important;
  }
  .has-gutter {
    display: none;
  }
  .el-row {
    margin: 20px 0;
  }
  .el-row .el-col {
    margin-left: 0 !important;
  }
}
</style>


